home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 016a / gofer221.zip / CAT < prev    next >
Text File  |  1991-11-20  |  789b  |  21 lines

  1. -- A version of the Unix utility cat coded up using the I/O facilities of
  2. -- Gofer, with a dash of Gofer overloading to enable the use of different
  3. -- argument forms:
  4. --
  5.  
  6. -- Here is a simple version, not using any overloading:
  7. -- (this version should work in Haskell)
  8.  
  9. unixCat :: [String] -> Dialogue
  10. unixCat  = foldr showFile done
  11.            where showFile name cont = readFile name abort
  12.                                       (\s->appendChan stdout s abort cont)
  13.  
  14. -- Now we get a little ambitious and write some Gofer-only code:
  15.  
  16. class    Cat a        where cat  :: a -> Dialogue
  17. instance Cat String   where cat n = showFile n done
  18. instance Cat [String] where cat   = foldr showFile done
  19.  
  20. showFile name cont = readFile name abort (\s->appendChan stdout s abort cont)
  21.